#!/usr/bin/python
# -*- coding: UTF-8 -*-
# -*- coding: UTF-8 -*-

import xml.sax
import xml.dom.minidom
import requestTest


def get_xml_ret(xmlStr, value):
    dom = xml.dom.minidom.parseString(str(xmlStr, encoding="utf-8").replace('gb2312', 'utf-8'))
    db = dom.documentElement
    name = db.getElementsByTagName(value)
    nameValue = name[0]
    return nameValue.firstChild.data


def get_xml_user(xmlStr, parent, child):
    dom = xml.dom.minidom.parseString(str(xmlStr, encoding="utf-8").replace('gb2312', 'utf-8'))
    db = dom.documentElement
    itemlist = db.getElementsByTagName(parent)
    item = itemlist[0]
    return item.getAttribute(child)


if __name__ == '__main__':
    # print requestTest.getxml()
    acStatusData = str(get_xml_ret(requestTest.getxml(), 'ret')).split(',')
    print(len(acStatusData))
    print(acStatusData[0:81])

    # print  getXmlUser('failLogin1', 'expected')